﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using Sebarf.Core.Interfaces;
using Sebarf.Services.Interfaces;
using Sebastof.Serialisation;
using Sebastof.Services.Interfaces;
using Utils;

#endregion

namespace Sebastof.ProcessChains.ProcessSteps {
	/// <summary>
	/// Description of the class
	/// </summary>
	public class DecorateObject : ProcessStepConverter<Object, ObjectTransportContainer> {
		#region Public Properties

		[ServiceRequest]
		public IServiceLocatorService ServiceLocatorService { get; set; }

		[ServiceRequest]
		public IObjectMappingLocatorService ObjectMappingLocatorService { get; set; }

		#endregion

		#region Public Methods

		public DecorateObject(IServiceLocatorService ctx) {
			ServiceLocatorService = ctx;
			ObjectMappingLocatorService = ServiceLocatorService.GetRegisteredService<IObjectMappingLocatorService>();
		}

		public DecorateObject() {
		}

		protected override ObjectTransportContainer Convert(Object toProcess) {
			return new ObjectTransportContainer(ServiceLocatorService, toProcess, ObjectMappingLocatorService);
		}

		public override bool CanProcess(object toProcess) {
			return base.CanProcess(toProcess) && !toProcess.GetType().Name.StartsWith("<>f__AnonymousType");
		}

		#endregion
	}
}